<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/10/29
 * Time: 15:42
 */

namespace app\admin\controller;


use think\Db;
use think\Request;

class Other extends Base
{
    /**
     * 顾问团
     * @return mixed|\think\response\Json
     */
    public function guwen(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 1)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 1)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/guwen');
    }
    
    /**
     * 机构团队介绍
     * @return mixed|\think\response\Json
     */
    public function mechanism(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 2)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 2)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/mechanism');
    }
    
    /**
     * 联盟介绍
     * @return mixed|\think\response\Json
     */
    public function league(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 3)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 3)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/league');
    }
    
    /**
     * 发起单位
     * @return mixed|\think\response\Json
     */
    public function company(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 4)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 4)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/company');
    }
    
    /**
     * 自训历史
     * @return mixed|\think\response\Json
     */
    public function history(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 5)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 5)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/history');
    }
    
    /**
     * 自训案例
     * @return mixed|\think\response\Json
     */
    public function selfCase(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 6)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 6)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/selfcase');
    }
    
    /**
     * 联盟成立大会
     * @return mixed|\think\response\Json
     */
    public function meeting(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 7)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 7)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/meeting');
    }
    
    /**
     * 贡献榜
     * @return mixed|\think\response\Json
     */
    public function gongxian(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 8)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 8)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/gongxian');
    }
    
    /**
     * 联系我们
     * @return mixed|\think\response\Json
     */
    public function touchUs(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 10)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 10)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/touchus');
    }
    
    /**
     * 响哨APP
     * @return mixed|\think\response\Json
     */
    public function xiangshao(){
        if(Request::instance()->isPost()){
            $params = input('param.');
            if(empty($params['other_content'])){
                return json(['code' => 100, 'msg' => '请填写内容']);
            }
            $update = [
                'other_content' => $params['other_content'],
                'other_update_time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_other')->where('other_id', 9)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $other = Db::table('up_other')->field('other_content')->where('other_id', 9)->find();
        $this->assign([
            'other' => $other,
        ]);
        return $this->fetch('other/xiangshao');
    }
}